/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.fd.manager.impl;

import com.xy.biz.fd.dao.DocumentCodeRuleDao;
import com.xy.biz.fd.domain.bo.DocumentCodeRuleBO;
import com.xy.biz.fd.domain.converter.DocumentCodeRuleConverter;
import com.xy.biz.fd.domain.converter.DocumentConverter;
import com.xy.biz.fd.domain.po.DocumentCodeRulePO;
import com.xy.biz.fd.domain.resp.GetDocumentCodeRuleResponse1;
import com.xy.biz.fd.domain.resp.GetDocumentResponse;
import com.xy.biz.fd.manager.DocumentCodeRuleManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 * 
 * @author zsp
 * @date 2021-4-29
 */
@Service
public class DocumentCodeRuleManagerImpl implements DocumentCodeRuleManager {

	@Autowired
	private DocumentCodeRuleDao documentCodeRuleDao;
	
	@Override
	public DocumentCodeRuleBO saveDocumentCodeRule(DocumentCodeRuleBO documentCodeRuleBO) {
		DocumentCodeRulePO documentCodeRulePO = DocumentCodeRuleConverter.toPO(documentCodeRuleBO);
		int row = documentCodeRuleDao.saveDocumentCodeRule(documentCodeRulePO);
		if (row == 0) {
			return null;
		}
		DocumentCodeRuleBO documentCodeRuleBO1 = DocumentCodeRuleConverter.fromPO(documentCodeRulePO);
		return documentCodeRuleBO1;
	}
	
	@Override
	public int updateDocumentCodeRule(DocumentCodeRuleBO oldDocumentCodeRuleBO, DocumentCodeRuleBO newDocumentCodeRuleBO) {
		return documentCodeRuleDao.updateDocumentCodeRule(DocumentCodeRuleConverter.toPO(oldDocumentCodeRuleBO), DocumentCodeRuleConverter.toPO(newDocumentCodeRuleBO));
	}
	
	@Override
	public int deleteDocumentCodeRule(Long documentCodeRuleId) {
		return documentCodeRuleDao.deleteDocumentCodeRule(documentCodeRuleId);
	}
	
	@Override
	public DocumentCodeRuleBO getDocumentCodeRule(String name) {
		return DocumentCodeRuleConverter.fromPO(documentCodeRuleDao.getDocumentCodeRule(name));
	}
	
}
